#include "TinyObjectPool.h"

#include <array>
#include <iostream>
#include <chrono>

using HugeObject = std::array<size_t , 4 * 1024 * 100>;
using HugeObjectPool = tinyUtil::TinyObjectPool<HugeObject>;
void processHugeObject(HugeObject * hugeObject) {
}

int main() {
    constexpr size_t N = 500000;

    std::cout << "Start loop using pool..." << '\n';
    HugeObjectPool pool;
    auto startUsingPool { std::chrono::steady_clock::now() };
    for (auto i = 0; i < N; ++i) {
        auto object { pool.acquireObject(1ULL, 2ULL, 3ULL) };
        processHugeObject(object.get());
    }
    auto endUsingPool { std::chrono::steady_clock::now() };
    std::cout << std::chrono::duration<double, std::milli>(endUsingPool - startUsingPool).count() << "ms" << '\n';

    std::cout << "Start loop using new/delete..." << '\n';
    auto startUsingND { std::chrono::steady_clock::now() };
    for (auto i = 0; i < N; ++i) {
        auto* object { new HugeObject({ 1ULL, 2ULL, 3ULL }) };
        processHugeObject(object);
        delete object; object = nullptr;
    }
    auto endUsingND { std::chrono::steady_clock::now() };
    std::cout << std::chrono::duration<double, std::milli>(endUsingND - startUsingND).count() << "ms" << '\n';
}
